<?php

namespace app\common\model;

use think\Model;

class VideoCollection extends Model
{
    // 表名
    protected $name = 'video_collection';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    
    // 追加属性
    protected $append = [
        'status_text',
        'is_recommend_text',
        'is_hot_text',
        'is_featured_text'
    ];
    
    public function getStatusList()
    {
        return ['0' => __('Hidden'), '1' => __('Normal')];
    }

    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : $data['status'];
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }
    
    public function getIsRecommendList()
    {
        return ['0' => __('No'), '1' => __('Yes')];
    }

    public function getIsRecommendTextAttr($value, $data)
    {
        $value = $value ? $value : $data['is_recommend'];
        $list = $this->getIsRecommendList();
        return isset($list[$value]) ? $list[$value] : '';
    }
    
    public function getIsHotList()
    {
        return ['0' => __('No'), '1' => __('Yes')];
    }

    public function getIsHotTextAttr($value, $data)
    {
        $value = $value ? $value : $data['is_hot'];
        $list = $this->getIsHotList();
        return isset($list[$value]) ? $list[$value] : '';
    }
    
    public function getIsFeaturedList()
    {
        return ['0' => __('No'), '1' => __('Yes')];
    }

    public function getIsFeaturedTextAttr($value, $data)
    {
        $value = $value ? $value : $data['is_featured'];
        $list = $this->getIsFeaturedList();
        return isset($list[$value]) ? $list[$value] : '';
    }
}